package com.iafme.controller;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iafme.dto.req.MemberReqDTO;
import com.iafme.dto.res.MemberResDTO;
import com.iafme.service.IMemberService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author summer
 * @date 2025-01-05 19:20
 */
@RestController
@RequestMapping(value = "/member")
@AllArgsConstructor
public class MemberController {


    private final IMemberService memberService;

    /**
     * 列表
     * @param memberReqDTO
     * @return
     */
    @PostMapping(value = "/lists")
    public Page<MemberResDTO> list(@RequestBody MemberReqDTO memberReqDTO){

        return memberService.lists(memberReqDTO);
    }

    @GetMapping(value = "/findAll")
    public List<MemberResDTO> lists(){

        return Convert.toList(MemberResDTO.class, memberService.list());
    }

    /**
     * 查看
     * @param id
     * @return
     */
    @GetMapping(value = "/findById/{id}")
    public MemberResDTO findById(@PathVariable Integer id){

        return memberService.findById(id);
    }



}
